package com.risen.test;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.UnsupportedEncodingException;

/**
 * @auther lmj
 * @date 2019/8/19
 */

@RunWith(SpringRunner.class)
@SpringBootTest
public class EncodeNameAndPath {

    @Test
    public void nameAndPath(){
        String[] names = new String[2];
        names[0] = "lADPDgQ9q2hZ8jXNC9DND8A_4032_3024.jpg_620x10000q90g.jpg";
        names[1] = "lADPDgQ9q2tL-6jNCZDNDMA_3264_2448.jpg_620x10000q90g.jpg";
        String[] paths = new String[2];
        paths[0] = "D:\\ideaspace\\springboot-mybatis\\target\\classes\\img";
        paths[1] = "D:\\ideaspace\\springboot-mybatis\\target\\classes\\img";
        try {
            String name = java.net.URLEncoder.encode(names.toString(), "UTF-8");
            String path = java.net.URLEncoder.encode(paths.toString(), "UTF-8");
            System.out.println("获取到的names为：" + name);
            System.out.println("获取到的paths为：" + path);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
}
